home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Games of Daze
/
Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso
/
djgpp
/
go32
/
fs
/
xsupport.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-03-23
|
7KB
|
226 lines
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <pc.h>
#include <dos.h>
#include <dpmi.h>
#include <go32.h>
#include <keys.h>
#define far
#include "ed.h"
#include "syms.h"
#include "paging.h"
#include "fsfuncts.h"
#include "xsupport.h"
#include "io.h"
int dummy_object_support (word32 addr);
void dummy_object_redraw (char *buf);
/* ---------------------------------------------------------------------- */
static word32
get_sym(char *prompt)
{
screen_attr = screen_attr_message;
if (my_read_string(prompt))
return 0;
screen_attr = screen_attr_normal;
return syms_name2val (read_buffer);
}
/* ---------------------------------------------------------------------- */
static int
get_num(char *prompt)
{
char *endp;
screen_attr = screen_attr_message;
if (my_read_string(prompt))
return 0;
screen_attr = screen_attr_normal;
return strtoul (read_buffer, &endp, 0);
}
/* ---------------------------------------------------------------------- */
static word32
get_addr (word32 addr)
{
word32 return_addr;
return_addr = get_sym("Address (Enter = Current): ");
if (!valid_addr (return_addr, sizeof (word32)))
return_addr = addr;
return return_addr;
}
/* ---------------------------------------------------------------------- */
int
extern_data_support(word32 addr)
{ return (dummy_object_support (addr));
}
/* ---------------------------------------------------------------------- */
void
redraw_xsupport (char *buf)
{ dummy_object_redraw (buf);
}
/* ---------------------------------------------------------------------- */
/* **********************************************************************
* *
* Example for using the xsupport module. *
* *
********************************************************************** */
static MENU_ITEM dummy_Object_Sub_Menu[] = {
{"Current item ", 1 , "" , 0},
{"Display by ind~E~x ", ITEM_TYPE, "e", 0},
{"Display by ~A~ddress ", ITEM_TYPE, "a", 0},
{"Display ~H~idden objects", ITEM_TYPE, "h", 0},
{"Display ~O~bject set ", ITEM_TYPE, "o", 0},
{"Display top ~I~nstances ", ITEM_TYPE, "i", 0},
{0 , 0 , "" , 0}
};
static MENU_ITEM dummy_Frame_Sub_Menu[] = {
{"Current item ", 1 , "" , 0},
{"Display by ~A~ddress", ITEM_TYPE, "a", 0},
{"Display ~B~uffer ", ITEM_TYPE, "b", 0},
{0 , 0 , "" , 0}
};
static MENU_ITEM dummy_Queue_Sub_Menu[] = {
{"Current item ", 1 , "" , 0},
{"~D~isplay Queue Descriptor", ITEM_TYPE, "d", 0},
{0 , 0 , "" , 0}
};
static MENU_ITEM dummy_Main_Menu[] = {
{"Current " , 1 , "" , 0 },
{"~O~bjects " , MENU_TYPE, "o", dummy_Object_Sub_Menu},
{"~F~rames " , MENU_TYPE, "f", dummy_Frame_Sub_Menu },
{"~Q~ueues " , MENU_TYPE, "q", dummy_Queue_Sub_Menu },
{"~L~og " , ITEM_TYPE, "l", 0 },
{"~H~elp " , ITEM_TYPE, "h", 0 },
{"~E~xit XSupport ", ITEM_TYPE, "e", 0 },
{0 , 0 , "" , 0 }
};
static WIN_TEXT my_win_text;
static int initialized = 0;
/* ---------------------------------------------------------------------- */
static void
dummy_disp_help ()
{
init_text (&my_win_text, "Help");
init_text (&my_win_text, "Help");
add_text (&my_win_text, "Use the <Log> entry in the menu to log the output pane.");
add_text (&my_win_text, "Use C-x C-w at any window to log the focused window.");
add_text (&my_win_text, " C-x C-f to view the log file.");
add_text (&my_win_text, " ");
add_text (&my_win_text, "All global and local keystrokes are still in effect.");
add_text (&my_win_text, "Use Esc C-p <Pane> to select a pane.");
add_text (&my_win_text, "To return to the original menu, use <Exit XSupport>");
text_win (my_win_text, 60, 20);
free_text (&my_win_text);
}
/* ---------------------------------------------------------------------- */
static void
init_internal_data_struct ()
{ initialized = 1;
}
/* ---------------------------------------------------------------------- */
int
dummy_object_support(word32 addr)
{
unsigned int index, num;
word32 new_addr;
int BarSelect, PopSelect;
if (!initialized) /* Should be checked in a real xsupport routine */
init_internal_data_struct ();
if (!initialized) /* Program has not been run ? */
{ message (CL_Error, "Program has not initialized its data.");
return (1);
}
dummy_object_redraw (read_buffer);
menu (dummy_Main_Menu, &BarSelect, &PopSelect);
switch (BarSelect)
{ case 1:
switch (PopSelect)
{ case 1:
index = get_num ("Enter an index: ");
break;
case 2:
new_addr = get_addr (addr);
break;
case 3:
new_addr = get_addr (addr);
break;
case 4:
new_addr = get_addr (addr);
break;
case 5:
num = get_num ("Instances: ");
break;
}
break;
case 2:
switch (PopSelect)
{
case 1:
new_addr = get_addr (addr);
break;
case 2:
num = get_num ("Buffer number: ");
break;
}
break;
case 3:
switch (PopSelect)
{
case 1:
new_addr = get_addr (addr);
break;
}
break;
case 4:
if (cols > 31 && rows > 12)
read_write_log (cols - 31, rows - 31 > 2 ? rows - 31 : 2,
cols - 1, rows - 1);
break;
case 5:
dummy_disp_help ();
break;
case 6:
return (1);
}
return (0);
}
/* ---------------------------------------------------------------------- */
void
dummy_object_redraw (char *buf)
{ int width = 30;
int x2 = cols - 1, x1 = x2 - width - 1;
int y2 = rows - 2, y1 = y2 - 12;
if (x1 < 0 || y1 < 0) /* Screen is too small */
return;
screen_attr = screen_attr_ffocus;
double_frame (x1, y1, x2, y2, "XSupport");
screen_attr = screen_attr_help;
sprintf (read_buffer, "Testing Object System Info");
putl (x1 + 1, y1 + 1, width, read_buffer);
sprintf (read_buffer, "--------------------------");
putl (x1 + 1, y1 + 2, width, read_buffer);
screen_attr = screen_attr_normal;
sprintf (read_buffer, "dummy_object_support ()");
putl (x1 + 1, y1 + 3, width, read_buffer);
sprintf (read_buffer, " doesn't know what these ");
putl (x1 + 1, y1 + 4, width, read_buffer);
sprintf (read_buffer, " data means");
putl (x1 + 1, y1 + 5, width, read_buffer);
show_menu_bar (dummy_Main_Menu);
}
/* ---------------------------------------------------------------------- */